package Iterator;

import java.util.Iterator;
public class Waitress {

    Menu dinerMenu;

    public Waitress(Menu menu) {
        this.dinerMenu = menu;
    }

    public void printMenu() {
        Iterator dinerIterator = dinerMenu.createIterator();
        printMenu(dinerIterator);
    }

    private void printMenu(Iterator iterator) {
        while (iterator.hasNext()) {
            MenuItem menuItem = (MenuItem) iterator.next();
            System.out.println(menuItem.getName());
        }
    }


}
